#ifndef CUSTOMWIDGETS_H
#define CUSTOMWIDGETS_H

#include <QPushButton>
#include <QPainter>
#include <QPaintEvent>
#include <QLabel>
#include <QGraphicsOpacityEffect>

class BigBtn : public QPushButton
{
private:
    bool pressed = false;
    int cornerRadius;

    QWidget* indicator;

    QColor bgColor;
    //button styleSheet
    QString defaultColor = "background-color:#07000000";
    QString hoverColor = "background-color:#1F0078D4";
    QString pressColor = "background-color:#3F0078D4";
    QString borderRadius = QString::asprintf("border-radius:%dpx;", cornerRadius);
    //indicator styleSheet
    QString indicatorDefaultStyle = "border-radius:3px;background-color:#afafaf";
    QString indicatorHoverStyle = "border-radius:3px;background-color:#0078d4";

protected:
    void enterEvent(QEvent* event) override;
    void leaveEvent(QEvent* event) override;
    void mousePressEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
    void resizeEvent(QResizeEvent* event) override;

public:
    BigBtn(QSize size, int radius, QWidget* parent);
    ~BigBtn() = default;
};

class SmallBtn : public QPushButton
{
private:
    int cornerRadius = 13;
    QWidget* indicator;
    int indicatorHeight = 2;

    //button styleSheet
    QString defaultColor = "background-color:#07000000";
    QString hoverColor = "background-color:#1F0078D4";
    QString pressColor = "background-color:#3F0078D4";
    QString borderRadius = QString::asprintf("border-radius:%dpx;", cornerRadius);
    //indicator styleSheet
    QString indicatorDefaultStyle = "border-radius:3px; background-color:#00000000";
    QString indicatorHoverStyle = "border-radius:3px; background-color:#0078d4";

protected:
    void enterEvent(QEvent* event) override;
    void leaveEvent(QEvent* event) override;
    void mousePressEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
    void resizeEvent(QResizeEvent* event) override;

public:
    SmallBtn(QSize size, int radius, QWidget* parent);
    SmallBtn(QSize size, QWidget* parent);
    SmallBtn(QWidget* parent) : QPushButton(parent) {};
    ~SmallBtn() = default;
};

class SelectionItem : public QWidget {
    Q_OBJECT
private:
    QLabel* title;
    QLabel* description;
    QWidget* indicator;
    QWidget* mainContent;
    QWidget* bgWidget;
    QGraphicsOpacityEffect* opac;   //
    bool onSelected = false;
    bool mousePressed = false;

    void enterEvent(QEvent* event) override;
    void leaveEvent(QEvent* event) override;
    void mousePressEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
    void resizeEvent(QResizeEvent* event) override;

public:
    SelectionItem(QString name, QString info = "", QWidget* parent = nullptr);
    ~SelectionItem(){};
    void select();
    void deselect();

signals:
    void selected(SelectionItem* item);

};

#endif // CUSTOMWIDGETS_H
